<% if File.directory?(path) %>
  <ul id="tree_ul" class="filetree">
    <% files = Dir.glob(File.join(path, "*")).sort{|a,b|[(File.directory?(a) ? 0 : 1), File.basename(a)] <=> [(File.directory?(b) ? 0 : 1), File.basename(b)]} %>
    <% files.each.with_index(1) do |file, index| %>
      <% show_file_path = show_file_path(file) %>
      <% if File.directory?(file) %>
        <li class="closed expandable <%= "last" if files.size == index%>">
          <%= link_to(show_file_path, class: "closed_dir") do %>
            <div class="hitarea closed-hitarea expandable-hitarea"></div>
          <% end %>
          <span class="<%= File.directory?(file) ? "folder" : "file"%>">
            <%= link_to(File.basename(show_file_path), action: :show, path: show_file_path) %>
          </span>
        </li>
      <% else %>
        <li class="<%= "last" if files.size == index%>"><span class="file"><%= link_to(File.basename(show_file_path), action: :show, path: show_file_path) %></span></li>
      <% end %>
    <% end %>
  </ul>
  <%= render partial: "treeview_script" %>
<% else %>
  <pre class="highlight brush: ruby"><%= File.read(path)  %></pre>
  <h2>Description</h2>
  <p>
    <% klass = get_class_for_path(path)%>
    <%= klass.try(:description) if klass.respond_to?(:description) %>
  </p>
<% end %>
